package com.zhs.study;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;

import java.util.Date;

/**
 * @author zhenghuisheng
 * @date : 2023/6/5
 */

public class People implements FactoryBean<Teacher>, ApplicationContextAware {

	private Long id;
	private String username;
	private Integer age;
	private String sex;
	private Date createTime;
	private Date updateTime;
	private Integer isDeleted;

	private ApplicationContext applicationContext;

	@Override
	public Teacher getObject() throws Exception {
		Teacher teacher = (Teacher)applicationContext.getBean("teacher");
		return teacher;
	}

	@Override
	public Class<?> getObjectType() {
		return Teacher.class;
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		this.applicationContext = applicationContext;
	}

	public People(Long id, String username, Integer age, String sex, Date createTime, Date updateTime, Integer isDeleted, ApplicationContext applicationContext) {
		this.id = id;
		this.username = username;
		this.age = age;
		this.sex = sex;
		this.createTime = createTime;
		this.updateTime = updateTime;
		this.isDeleted = isDeleted;
		this.applicationContext = applicationContext;
	}

	public People() {
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getUsername() {
		return username;
	}

	public void setUsername(String username) {
		this.username = username;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public Date getUpdateTime() {
		return updateTime;
	}

	public void setUpdateTime(Date updateTime) {
		this.updateTime = updateTime;
	}

	public Integer getIsDeleted() {
		return isDeleted;
	}

	public void setIsDeleted(Integer isDeleted) {
		this.isDeleted = isDeleted;
	}
}
